home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Whiteline: delta
/
whiteline CD Series - delta.iso
/
document
/
hypertxt
/
ximgtool
/
ximgtool.eng
< prev
next >
Wrap
Text File
|
1995-11-25
|
10KB
|
229 lines
Documentation for XIMGTOOL and IMGCODEC-sourcecode
Version: Apr 25 1995
1. Overview
"""""""""""
Hereby an extension of the IMG format for monochrome and color
palette images is given. The purpose was to generalize the known
IMG codec method as far as possible and thereby to increase the
achievable compression ratio, without introducing completely new
algorithms.
The result is the definition of 3 stages of the IMG format, called
Level 1, 2, and 3. Level 1 is thereby the 'compatibility'-Level,
that is identical with the old method. Level 2 and 3 define certain
extensions in a way, that an appropriate decoder is able to handle
the lower Levels without additional effort. Such a decoder is pro-
vided in sourcecode and is designed for flexible usage in applica-
tion programs. The utility XIMGTOOL demonstrates the usage of the
decoder as well as the given encoders and should serve as a tool
for arbitrary conversion between Levels. Furthermore, at the same
time with the hereby published tool and the sources a new 1STGUIDE-
version is released which already includes the Level-3-Decoder, so
it can be used for the practical proof of the methods.
The effect of the achieved improvements in compression ratio by the
extensions varies and depends on the type of the images. Especially
at typical screen snapshots of desktop scenes or line- or object-
drawings significant savings of 15 % average, in some cases around
30 %, were achieved. Fewer savings occur in photo-style images, but
also here a couple of KBytes can be saved at typical material.
2. Level-Definition
"""""""""""""""""""
The Level of an IMG file is marked by writing the according number
into the 'IMG-version' entry of the IMG header. This is the first
word in the file and therefore is easy to recognize in a hex dump.
Until now there was found the value 1. This is now interpreted as
Level-1. At a Level-2 coded image here is now written the value 2,
at Level-3 the value 3. This is mainly thought for information
purposes only, because the recommended and provided Level-3-Decoder
works independently from this value!
Some programs check for the version number and warn the user, if
this value is greater than 1. This is correct, because the programs
probably won't work well yet with the here defined extensions.
Other programs (so also older versions of 1STGUIDE) produce 'screen
garbage', if you try to load Level-2 or Level-3 images with them.
A program, which checked for maximum version number 1 so far, can
make a test for maximum 3 after built in the Level-3-Decoder, to
remain reliability.
Now a short description of the features of the different Levels
is given (see in the sourcecodes for details):
Level-1:
--------
Compatibility, so should be processable by all programs, which
already handled IMG files correctly so far.
- Compression methods are restricted to planes, that is neither
plane- nor line-overflow is allowed within a packing mode.
- vertical replication count (vrc): 1 to 255 times repeat the
current line.
- pattern run: 1 to 255 times repeat a pattern.
- solid run: 1 to 127 times repeat a 0/0xFF-byte.
- byte string: Copy the next 1 to 255 bytes.
Level-2:
--------
- Packing modes need not longer be restricted to the planes of a
line. But the line-limit is going on to be a restriction.
- At vertical replication count (vrc) and byte string a zero byte
count value is interpreted as a count of 256.
- Introduction of 'extended vertical run mode': Coding of a repea-
ted byte sequence in respect to the line before by specially in-
terpreted stuffing byte 0xFF of 'full' vrc. This can be considered
as generalization of the 'full vrc' to repeated partial sequences
of a line.
Level-3:
--------
- Here we get away with any restriction of packing modes to
line-limits too! Thanks to the used ('object oriented') data
structures, only a single line buffer is still required for
decoding.
- All mentioned Level-2 extensions are valid here too, of course.
The effect of the extensions on the compression ratio does, as
mentioned, vary. Especially the 'extended vertical run mode' in-
troduced with Level-2 provides significant savings on some images,
while being meaningless on others.
The removed plane-limit-coding at Level-2 has, of course, the grea-
ter effect, the more planes (colors) are given. In monochrome images
this has no effect, here the achieved savings are mainly due to the
extended vrc.
The removed line-limit-coding at Level-3 allows little savings
over Level-2 - nearly 1 byte per line average, sometimes less,
sometimes more. Try this out and make your own experiences!
3. XIMGTOOL.TTP
"""""""""""""""
With this utility you have the possibility to extensively test and
use the capabilities of the various image coding methods.
Usage: ximgtool [options] input [output]
options:
-lN:
----
Use Level-N-Encoder, N=1..3. Default is input value cropped to 1..3.
So if you want to compress given IMG files (Level-1) with a maximum
degree, write -l3. The so produced files may, of course, only be
decompressed and viewed by capable (Level-3) decoders, at the moment
this is the current 1STGUIDE-version. Other programs will hopefully
follow soon. But you can use this nevertheless for instance for
archiving of images: With XIMGTOOL you can convert back the files to
the compatible Level-1 for reuse with other programs if necessary.
To do this write -l1. XIMGTOOL itself always uses the universal
Level-3-Decoder.
The used and provided encoders are already the result of an inten-
sive optimization process. So even the compatible Level-1-Encoder
usually produces smaller files than the most effective programs so
far that I know. Only in very rare cases a little loss occured. So
the optimum isn't reached yet with the given encoders and further
enhancements are possible in the future, while the decoder should
not allow significant changes.
-pN:
----
Force output pattern run N, N=1..2. Default is input value cropped
to 1..2.
The pattern run is a global IMG variable and therefore does not
allow to be optimized in a single pass. Some images achieve higher
comression ratios at 1, other at 2. You have to try this out if you
want the optimum, but mostly the difference is not that great (a few
bytes), so it isn't worth to worry too much.
-i:
---
Identify input, no coding.
-m:
---
Multiple mode (batch). Allows use of a standard wildcard pattern as
input to process multiple files in a directory. ATTENTION for
GEMINI-users: In the console window you have to 'quote' the wildcard
pattern to prevent the shell from automatic argument expansion!
As output a destination folder may be given.
input: source file (pattern if -m).
output: destination file (folder if -m).
After processing some statistics are shown: the number of input
bytes, output bytes, and the difference between them (saved bytes).
The latter is usually positive (saving) if converting to a higher
Level, and negative (wasting) if converting to a lower Level.
Note: Also without giving an 'output' a full coding is done (then
only in memory), and the according results are displayed. This can
be useful for testing purposes.
An extended XIMG-header is completely ignored by XIMGTOOL, it is
directly copied into the output file.
4. IMGCODEC-Sourcen
"""""""""""""""""""
In order to force an easy and widespread usage, complete sources for
coding and decoding are provided. Look at the included comments for
details.
While, as mentioned above, the given decoder does not allow signi-
ficant changes, the encoders do probably allow to be optimized yet,
although some effort has already been spent on them. The encoders
are designed to take advantage of all available coding schemes, and
an own vrc-handling is done independently from the input coding.
So for the same image contents there should be always the same
result, not depending on the input coding.
If you find enhancements of the encoders, you are welcome to make it
available. But be aware: It is easy to construct an encoder that
wins on special contents, but looses more on others. It always
depends on the test material, this should be as great and applica-
cation-typical as possible. Only if you find a routine which pro-
vides significant savings on typical images and which only looses
little in exceptional cases, it can be generally considered.
Aside from the raw codec-sources you will find application examples
for MFDB-input and -output, which can serve as sample for appro-
priate applications.
5. Preview
""""""""""
Presently the extension of the IMG format for True-Color-support
(generally Direct-Color, since High-Color-modes will be included,
too) is prepared. Because secondary processing of this type is
somewhat more sophisticated, the given Level-Specification should
be published first to satisfy some interested people who asked for
this. The TC-extension will be independent from the given Level-
Spec, and the current routines will work with this extension with-
out changes, since this extension deals only with specifying an
extended IMG-header for appropriate interpretation of pixel data.
The pixel data itself is handled by the same scheme.
The XIMGTOOL.TTP will also be useful for the TC-files, since it
works independently from the extended header information and in-
terpretation of pixel data.
6. Reference
""""""""""""
If you have comments or suggestions, please write to the following
address:
Guido Vollbeding
Turmstraβe 61
D-06110 Halle (Saale)
Germany